package com.aaa.entity;


import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;

import java.util.Collection;

@Data
@NoArgsConstructor
@AllArgsConstructor
@TableName("emp")
public class Emp implements UserDetails {
@TableId(type = IdType.AUTO)
private Integer empid;
  private String      ename;
private String  eusername;
  private String        epassword;
private String  phone;
private String          sex;
private Integer  photo;
private Integer          roleid;
 private Integer state;



  @TableField(exist = false)//该字段不使用
    private Collection authorities;

    public void setAuthorities(final Collection authorities) {
        this.authorities = authorities;
    }

    //获取权限
    @Override
    public Collection<? extends GrantedAuthority> getAuthorities() {
        return this.authorities;
    }
    //获取密码
    @Override
    public String getPassword() {
        return this.epassword;
    }
    //获取密码
    @Override
    public String getUsername() {
        return this.ename;
    }
    //用户是否过期
    @Override
    public boolean isAccountNonExpired() {
        return true;
    }
    //用户是否锁定
    @Override
    public boolean isAccountNonLocked() {
        return true;
    }

    // 凭证是否过期:密码
    @Override
    public boolean isCredentialsNonExpired() {
        return true;
    }

    @Override
    public boolean isEnabled() {
        return true;
    }
}
